package com.omesoft.hksnore.util.omeview;

import android.content.Context;

/**
 * Created by Omesoft on 2017/3/7.
 */

public class Utils {
    public static int dip2px(Context context, float dipValue) {
        final float density = context.getResources().getDisplayMetrics().density;
//	    Log.v("test","density:"+density);
        return (int)(dipValue * (density ));
    }

    public static int px2dip(Context context, float pxValue) {
        final float density = context.getResources().getDisplayMetrics().density;
        //	Log.v("test","density:"+density);
        return (int) (pxValue / ((density )));
    }

    public static int px2sp(Context context, float pxValue) {
        final float density = context.getResources().getDisplayMetrics().scaledDensity;
        //	Log.v("test","density:"+density);
        return (int) (pxValue / ((density ))+0.5f);
    }

    public static int sp2px(Context context, float spValue) {
        final float density = context.getResources().getDisplayMetrics().scaledDensity;
//	    Log.v("test","density:"+density);
        return (int)(spValue * (density )+0.5f);
    }

}
